using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;


namespace Elementum
{
    /// <summary>
    /// This is a game component that implements IUpdateable.
    /// </summary>
    public class RenderObject :VisibleObject
    {

        //protected const float PI = 3.14159f;

        protected PrimitiveBatch primitiveBatch;

        protected Game _game;

        public RenderObject(Game game)
        {
            this._game = game;
            primitiveBatch = new PrimitiveBatch(game);
        }

        public GraphicsDevice GraphicsDevice
        {
            get { return _game.GraphicsDevice; }
        }

        public float count;

        protected virtual void DrawFan(Vector2 position, float radius, float angle)
        {
            primitiveBatch.Begin(PrimitiveType.TriangleList);

            float baseAngle = 0;

            for (int i = 0; i <= angle; i++)
            {
                primitiveBatch.AddVertex(position, Color.White);
                float _angle1 = (  baseAngle + i)*PI/180f;
                float _angle2 = (  1 + baseAngle + i)*PI/180f;
                primitiveBatch.AddVertex(position + new Vector2((float)Math.Cos(_angle1), (float)Math.Sin(_angle1)) * radius, Color.White);
                primitiveBatch.AddVertex(position + new Vector2((float)Math.Cos(_angle2), (float)Math.Sin(_angle2)) * radius, Color.White);
            }

            primitiveBatch.End();
        }

        public virtual void Initialize()
        {
            
        }

        //public virtual void OnDraw(Vector2 position,Matrix transform) 
        //{
        //    count += 0.5f;

        //    if (count >= 360)
        //        count = 0;

        //    Vector2 vs;
        //    if (transform == null)
        //        vs = new Vector2();
        //    else
        //        vs= new Vector2(transform.Translation.X, transform.Translation.Y);

        //    // DrawShip(new Vector2(100, 400 / 2));
        //    DrawFan(position+vs, 200f, count);
        //} 


        public override void OnDraw(SpriteBatch spriteBatch, Matrix transform)
        {
            base.OnDraw(spriteBatch, transform);
        }

        public override void Update(int delta)
        {
            base.Update(delta);
        }
    }
}
